Skip to content

perf(vulkan2d): upload the font atlas once per flush; css-layout 3 submits -> 1 - #633

Merged
ormastes merged 2 commits into
mainfrom
work/vulkan-atlas-upload-once-2026-09-12
Sep 12, 2026
Merged

ormastes merged 2 commits into
mainfrom
work/vulkan-atlas-upload-once-2026-09-12

Conversation

@ormastes

Copy link
Copy Markdown
Owner

The GPU-boundary audit gate had two residuals on the Vulkan web-renderer lane.

(a) The font atlas was copied to the device once per text run. Each run that
inserts a glyph bumps the owner's published sequence, so the slot plan is
WRITE_IN_PLACE, and that branch copied the full 1024x1024 atlas (4 MiB) every
time — ~15 copies, ~60 MB, on a page with one atlas. All but the last are dead:
within a flush the atlas only grows (cells are inserted, never relocated — the
invariant WRITE_IN_PLACE already rests on), and every dispatch that reads it is
recorded into the same not-yet-submitted command buffer. The typed (u32) lane
now parks the copy and drains it immediately before the submit. A park aimed
at a different buffer drains the previous one first; release paths discard a park
rather than drain into a doomed buffer; a failed drain poisons only that slot.
The byte fallback lane is unchanged.

(b) css-layout.html reported submits_per_frame=3. Two causes, both found
with the tagged SIMPLE_VK_ORDER_TRACE flush trace (a permanently armed
font-slot line now records the whole slot decision):

  1. A zero-area opaque rect reached the device arm and produced 0 workgroups. The
    enqueue's silent argument reject was read as the measured M4 bind-chain flake,
    costing a full flush (an extra submit), a futile retry with the same invalid
    arguments, and a CPU-fallback latch. Guarded at the call site and, generally,
    in _dispatch_framebuffer_checked (dispatch-reject: no flush, no retry).
  2. A relocating WRITE_FRESH left the owner's name on its OLD slot at a stale
    sequence; the first-match lookup found the stale one forever and the table
    exhausted into a FLUSH_THEN_WRITE. A write now disowns every other slot
    naming that owner, and the table is 8 deep (an owner folds point SIZE into its
    identity, so css-layout presents five owners from two families).

Evidence — audit gate, same binary (39528776 1789199850)

page uploads/frame upload_ms submits/frame fences frame_digest verdict
overview before 23 43 1 1 a15c50cd PASS
overview after 13 19 1 1 a15c50cd PASS
css-layout before 47 57 3 3 743c2081 FAIL
css-layout after 25 32 1 1 743c2081 PASS

frame_digest identical on both pages is the pixel oracle; cpu_fallback_count=0
on both.

Specs (simple run): slot_plan 12/12, font_typed_upload 4/4, quad_partition 7/7,
drawing 44/44. Four sibling vulkan specs report outcome=ERROR executed=0 from a
pre-existing unresolved use gpu.engine2d.engine.{Engine2D} (E1034) in the
spec files — unrelated to these sources.

Guards: conflict-markers PASS, tree-size PASS, rt-dual-implementation PASS
(2519/2519), all four *-spirv-pinned PASS, guard-wiring PASS after the second
commit wires the two orphaned SPIR-V pin gates (blur-rect, glass-material) that
were the only NEW unwired guards on main. Divergence-delta: PASS — 3209
pre-existing offenders, 0 introduced.

Record: doc/08_tracking/bug/vulkan_font_atlas_reupload_per_run_and_css_layout_submits_2026-09-12.md

🤖 Generated with Claude Code

https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi

ormastes and others added 2 commits September 12, 2026 20:11
…ayout's two extra submits

(a) The typed atlas upload is now PARKED and drained immediately before the
submit instead of copying the full 4 MiB atlas once per text run. Within a
flush the atlas only grows (cells are inserted, never relocated -- the
invariant WRITE_IN_PLACE already rests on) and every dispatch that reads it is
recorded into the same not-yet-submitted command buffer, so the final copy is
observationally identical to the fifteen it replaces. A park aimed at a
different buffer drains the previous one first; release paths discard a park
rather than drain into a doomed buffer; a failed drain poisons only that slot.
The byte fallback lane is untouched.

(b) css-layout.html's submits_per_frame=3 had two causes, both found with the
tagged SIMPLE_VK_ORDER_TRACE flush trace (a new, permanently armed `font-slot`
line records the whole slot decision):
  * a zero-area opaque rect reached the device arm, produced 0 workgroups, and
    the enqueue's silent argument reject was read as the M4 bind-chain flake --
    costing a full flush, a futile retry with the same arguments, and a CPU
    fallback latch. Guarded at the call site and, generally, in
    _dispatch_framebuffer_checked (dispatch-reject: no flush, no retry).
  * a relocating WRITE_FRESH left the owner's name on its OLD slot at a stale
    sequence; the first-match lookup then found the stale one forever and the
    table exhausted into a FLUSH_THEN_WRITE. A write now disowns every other
    slot naming that owner, and the slot table is 8 deep (an owner folds point
    SIZE into its identity, so css-layout presents five owners from two
    families).

Gate evidence, same binary (39528776/1789199850), digests unchanged:
  overview.html   uploads 23->13, upload_ms 43->19, submits 1, digest a15c50cd, PASS
  css-layout.html uploads 47->25, upload_ms 57->32, submits 3->1, fences 3->1,
                  digest 743c2081, FAIL->PASS

Specs green (simple run): slot_plan 12/12, font_typed_upload 4/4,
quad_partition 7/7, drawing 44/44. Four sibling vulkan specs report
outcome=ERROR executed=0 from a pre-existing unresolved `use gpu.engine2d.*`
import in the spec files; unrelated to these sources.

Record: doc/08_tracking/bug/vulkan_font_atlas_reupload_per_run_and_css_layout_submits_2026-09-12.md

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi
…into the push tier

Both landed with no hook and no CI job invoking them, so check-guard-wiring
reported them as the only 2 NEW unwired guards on origin/main. They are the
same shape as the already-wired rect-batch and blit pin gates: ~1s, no device,
fail-closed with their own 4-fixture selftest, and both PASS today. Added as
blocking push-tier manifest rows with byte-matching dispatch arms.

Divergence-delta step-over recorded: PASS — 3209 pre-existing offender(s), 0
introduced by this range (base verdict FAIL 3943 diverged vs 965 baselined is
pre-existing on origin/main).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi
@ormastes
ormastes merged commit 74d8b60 into main Sep 12, 2026
9 of 35 checks passed
@ormastes
ormastes temporarily deployed to self-review-admission September 12, 2026 11:22 — with GitHub Actions Inactive
@ormastes
ormastes deleted the work/vulkan-atlas-upload-once-2026-09-12 branch September 12, 2026 11:22

This branch was previously deployed

1 inactive deployment
self-review-admission — adc0b021 Deployed Sep 12, 2026 by ormastes via Invalidate changed PR self-review state #4179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant